package txmusic;

public class MaxValue {

    public static void main(String[] args) {
        System.out.println(maxValue("321", 2));
    }

    public static int maxValue (String s, int k) {
        // write code here
        String maxValue = s.substring(0, k);
        for (int i = 1; i <= s.length() - k; i++){
            String tmp = s.substring(i, i + k);
            if (maxValue.compareTo(tmp) < 0){
                maxValue = tmp;
            }
        }
        return Integer.parseInt(maxValue);
    }
}
